package cn.wolfcode.web.controller;

import cn.wolfcode.mq.MQConstant;
import cn.wolfcode.service.IOrderInfoService;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(consumerGroup = "orderSuccessGroup",topic = MQConstant.ORDER_PAY_TIMEOUT_TOPIC)
public class OrderSuccessMessageListener implements RocketMQListener<MessageExt> {
    @Autowired
    private IOrderInfoService orderInfoService;

    @Override
    public void onMessage(MessageExt messageExt) {
        String orderNo = new String(messageExt.getBody());
        // 超时取消
        orderInfoService.cancelOrder(orderNo);
        System.out.println();
    }
}
